package cloud.shyidong.admin.tentant.controller;

import cloud.shyidong.admin.tenant.service.TenantTenantService;
import cloud.shyidong.core.controller.AbstractController;
import cloud.shyidong.core.request.IdsRequest;
import cloud.shyidong.core.request.LongIdRequest;
import cloud.shyidong.tenant.dao.TenantTenantDao;
import cloud.shyidong.tenant.entity.TenantTenantEntity;
import cloud.shyidong.tenant.request.TenantTenantInsertRequest;
import cloud.shyidong.tenant.request.TenantTenantPageRequest;
import cloud.shyidong.tenant.request.TenantTenantUpdateRequest;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;

/**
 * <p>
 * 租户控制器
 * </p>
 *
 * @author syd
 * @since 2023-08-24 15:55:13
 */
@RestController
@RequestMapping("/tenant-tenant")
@Slf4j
public class TenantTenantController extends AbstractController<TenantTenantService, TenantTenantDao, TenantTenantEntity, LongIdRequest, TenantTenantInsertRequest, TenantTenantUpdateRequest, TenantTenantPageRequest> {
    
    /**
     * 试用
     *
     * @param idsRequest
     * @return
     */
    @PostMapping(value = "/approvals", consumes = {"application/json"})
    public Map<String, Object> probations(@RequestBody @Valid IdsRequest<LongIdRequest> idsRequest) {
        if (log.isDebugEnabled()) {
            log.debug("approval param >>> {}", JSON.toJSONString(idsRequest));
        }
        return this.getService().approvals(idsRequest);
    }
    
    /**
     * 认证
     *
     * @param idsRequest
     * @return
     */
    @PostMapping(value = "/auths", consumes = {"application/json"})
    public Map<String, Object> normals(@RequestBody @Valid IdsRequest<LongIdRequest> idsRequest) {
        if (log.isDebugEnabled()) {
            log.debug("auth param >>> {}", JSON.toJSONString(idsRequest));
        }
        return this.getService().auths(idsRequest);
    }
    
}

